package cmd

/**
import (
	"svr/src/conf"
	"svr/src/internal/logic"
	"svr/src/msg"
	"svr/src/ws"

	"google.golang.org/protobuf/proto"
)

func init() {
	ws.AddHandler(&msg.ClientEnterR{}, handlerClientEnterR)
}

func handlerClientEnterR(mr proto.Message, task *ws.MsgTask) *msg.Error {
	msgR := mr.(*msg.ClientEnterR)
	msgA := &msg.ClientEnterA{}
	di := task.Dev
	di.Type = msg.DeviceType_ClientUser
	if conf.ServerConfig.ServerType != msg.DeviceType_SingleLogic && conf.ServerConfig.Balance == msg.BalanceType_Alloc { //不是单服模式，并且是负载服
		di, mer := ws.GetConnectDevice(msg.DeviceType_ServerTransmit, true) //!#//把找到的转发服发给客户端，转发服有可能换
		if mer != nil {
			return task.ReturnMsg(msgA, mer)
		}
		svr := &msg.ServerInfo{
			Type:       di.Type,
			AddrListen: di.AddrListen,
		}
		msgA.ToServer = svr //有这个值，其他值不用了。
		return task.ReturnMsg(msgA)
	}
	ws.AddDeviceToMapGroup(di) //这里注册客户端
	am := logic.GetAccountManager()
	var sysErr, logicErr *msg.Error
	var AccountId uint64
	if msgR.IsLogin { //登陆
		sysErr, logicErr, AccountId = am.AccountLoginEnter(msgR.Accout, msgR.Password)
	} else { //注册
		sysErr, logicErr, AccountId = am.RegisterAccountEnter(msgR.Accout, msgR.Password)
	}
	if sysErr != nil {
		return task.ReturnMsg(msgA, sysErr)
	}
	msgA.Err = logicErr
	msgA.SvrDevType = conf.ServerConfig.ServerType
	msgA.AccountId = AccountId

	return task.ReturnMsg(msgA)
}
/**/
